from django.urls import path, re_path, include
from . import views
from . import views2
from django.views.decorators.cache import cache_page

from django.contrib.auth.decorators import login_required

app_name = 'article'

urlpatterns = [
    path('article/', include([
        path('add/', views.ArticleAdd.as_view(), name="add"),
        path('list/', views.article_list, name="list"),
        # path('',views.article_list,name="index"),
        # path('detail/<int:pk>',views.article_detail,name="detail"),
        path('delete/<int:id>', views.article_delete, name="delete"),
        path('edit/<int:id>', views.article_edit, name="edit"),
        path('detail/<int:pk>', views2.ArticleDetailView.as_view(), name="detail"),
    ])),

    path('search/', views2.search, name='search'),
    path('archives/<int:year>/<int:month>/', views.archive, name='archive'),
    path('categories/<int:pk>/', views.CategoryView.as_view(), name='categories'),
    # path('tags/<int:pk>/', views.TagView.as_view(), name='tags'),

    # 标签搜索文章列表
    path('tags/<slug:tagslug>/', views2.CategoryView.as_view(), name='tags'),

    # 标签搜索ajax请求
    path('ajax/tag/', views2.TagAjax),
    # 一级二级菜单分类文章列表
    re_path(r'category/(?P<bigslug>.*?)/(?P<slug>.*?)/', views2.CategoryView.as_view(), name='category'),
    # django 2.x中用re_path兼容1.x中的url中的方法（如正则表达式）# ?分隔实际的URL和参数,?p数据库里面唯一索引 & URL中指定的参数间的分隔符
    re_path(r'category/(?P<bigslug>.*?)/', views2.CategoryView.as_view(), name='bigcategory'),

    path('course/detail/<int:pk>', views2.CourseArticleDetailView.as_view(), name="course_detail"),

]
